import cn.lu.pojo.User;
import cn.lu.utils.Result;
import com.alibaba.fastjson.JSONObject;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class testRedis {
    @Test
    public void testRedisPool(){
        JedisPoolConfig poolConfig = new JedisPoolConfig();
        JedisPool pool = new JedisPool(poolConfig,"121.36.51.254",6379,1000,"zhoulu");
        Jedis jedis = pool.getResource();

        String s = jedis.get("9e4a18c9-66c4-4424-8249-9d85f676d022");
        System.out.println(s);
        User user = JSONObject.parseObject(s, User.class);
        System.out.println(user);
    }


    @Test
    public void testSpringJedisSingle(){
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:spring-redis.xml");
        JedisPool jedisPool = (JedisPool) applicationContext.getBean("jedisPool");
        Jedis jedis = jedisPool.getResource();
        String s = jedis.get("1");
        System.out.println(s);
    }
}
